﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Model.Documents;
using IsmsExplorer.Infrastructure.Helper;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;

namespace IsmsExplorer.Infrastructure.Repositories.Documents {
    internal class Iso27001ControlDocumentationFactory : IEntityFactory<Iso27001ControlDocumentation> {
        internal static class FieldNames {
            public const string ProjectID = "ProjectID";
            public const string DocumentID = "DocumentID";
            public const string ControlID = "ControlID";
        } // end internal static class FieldNames

        public Iso27001ControlDocumentation BuildEntity(System.Data.IDataReader reader) {
            // Loading only the ProjectID and ControlID which we expect to find in the reader.
            // The rest of the information (i.e. the documents associated with the control for the given project) 
            // will be retrieved separately (potentially in the Repository object method which called us).
            // The associated control will be loaded via child callbacks.
            return new Iso27001ControlDocumentation() {
                ProjectID = DataHelper.GetInteger(reader[FieldNames.ProjectID])
            };
        }

    }
}
